<?php

class ServiceController extends Controller
{
	
	public function init()
	{
		$this->layout='column1';
	}
	
	/**
	 * Declares class-based actions.
	 */
	public function actions()
	{
		return array(
			// captcha action renders the CAPTCHA image displayed on the contact page
			'captcha'=>array(
				'class'=>'CCaptchaAction',
				'backColor'=>0xFFFFFF,
			),
			// page action renders "static" pages stored under 'protected/views/site/pages'
			// They can be accessed via: index.php?r=site/page&view=FileName
			'page'=>array(
				'class'=>'CViewAction',
			),
		);
	}

	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function actionIndex()
	{
		if(!Yii::app()->user->isGuest) {
			$this->render('index');
		} else {
			$this->redirect(Yii::app()->user->loginUrl);
		}
		
	}
	

	/**
	 * This is the action to handle external exceptions.
	 */
	public function actionError()
	{
	    if($error=Yii::app()->errorHandler->error)
	    {
	    	if(Yii::app()->request->isAjaxRequest)
	    		echo $error['message'];
	    	else
	        	$this->render('error', $error);
	    }
	}

	/**
	 * Displays the 城市交通整治与管理咨询
	 */
	public function actionManage()
	{
		if(!Yii::app()->user->isGuest) {
			$this->render('mange');
		} else {
			$this->redirect(Yii::app()->user->loginUrl);
		}
	}

	/**
	* Displays the 城市综合形象提升与宣传
	*/
	public function actionPromote()
	{
		if(!Yii::app()->user->isGuest) {
			$this->render('promote');
		} else {
			$this->redirect(Yii::app()->user->loginUrl);
		}
	}
	
	/**
	* Displays the 城市资源开发与管理
	*/
	public function actionDev()
	{	
		if(!Yii::app()->user->isGuest) {
			$this->render('dev');
		} else {
			$this->redirect(Yii::app()->user->loginUrl);
		}
	}
	
	/**
	* Displays the 城市人才引进与培训
	*/
	public function actionTrain()
	{		
		if(!Yii::app()->user->isGuest) {
			$this->render('train');
		} else {
			$this->redirect(Yii::app()->user->loginUrl);
		}
	}
}